<?php

ini_set("display_errors", "On");
error_reporting(E_ALL);

// 引入数据库连接文件
require_once '../../../sql/connection.php';

$courseID = $_POST['addCourseID'];
$addName = $_POST['addName'];
$addJType = (int)$_POST['addJType'];
$addJobTotalPoints = $_POST['addJobTotalPoints'];

// 查询语句
$querySql = "select id, create_time, update_time, name, is_delete from permission_info where name='$addName'";
// 连接数据库，并查询
$result = mysqli_query($GLOBALS['conn'], $querySql);

$now = date('Y-m-d H:i:s', time());
$addSql = "INSERT INTO job_info(create_time, update_time, course_ID, job_name, job_type, question_total, job_total_points,  is_delete)
						VALUES ('$now','$now','$courseID','$addName','$addJType',0 ,'$addJobTotalPoints',0)";

if (mysqli_query($GLOBALS['conn'], $addSql)) {
	echo "
            <script>
                alert('添加成功！');
                window.location.href=document.referrer;
            </script>
        ";
} else {
	echo "
            <script>
                alert('添加失败！');
                history.back();
            </script>
        ";
}

